<template>
  <el-card>
    <el-table
      :data="Category1list"
      style="width: 100%"
      row-key="id"
      border
      lazy
      :load="load"
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column prop="id" label="分类id" width="280"> </el-table-column>
      <el-table-column prop="name" label="分类名称" width="450">
      </el-table-column>
      <el-table-column prop="address" label="操作" align="center">
        <template #header>
          <el-input placeholder="按enter搜索三级分类"></el-input>
        </template>
        <el-button icon="el-icon-plus" type="primary" size="mini"></el-button>
        <el-button icon="el-icon-edit" type="warning" size="mini"></el-button>
        <el-button icon="el-icon-delete" type="danger" size="mini"></el-button>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
import {
  reqCategorylist1,
  reqCategorylist2,
  reqCategorylist3,
} from "@/api/product/Category";
export default {
  data() {
    return {
      Category1list: [],
    };
  },
  methods: {
    load(tree, treeNode, resolve) {
      resolve: async () => {
        if (item.level === 1) {
          const result = await reqCategorylist2();
        }
      };
    },
    async getCategort1list() {
      const result = await reqCategorylist1();
      console.log(result);
      if (result.code == 200) {
        this.Category1list = result.data;
        this.Category1list.forEach((item) => {
          item.hasChildren = true;
          item.level = 1;
        });
      }
    },
  },
  mounted() {
    this.getCategort1list();
  },
};
</script>

<style>
</style>